' ------------------------------------------------------------------------------------ ' This is a simple HTML generator written in VBScript ' ' It uses the current album or a user specified album to build a Framed HTML file. ' This file processes all the selected pictures. ' This is version 4 which includes the FORM tags so that the forms are created in Netscape ' ------------------------------------------------------------------------------------ Option Explicit ' To run this script outside of MyAlbum, un-comment the 2 following lines: 'dim app 'set app = CreateObject("MyAlbum.Application") app.ClearTrace Dim alb, pic if GetAlbum( alb ) then MsgBox( "This script will add the selected pictures to a Framed HTML page. If you want alternate text to show when mouse is over the thumbnail, First fill out the Information field for each pic in the album by right mouse clicking on the pic and selecting Information. Please select OK to continue") 'app.Trace "Output file = " & outputFileName Dim outputFileName outputFileName = InputBox( "Please enter the name of the INDEX HTML file to create", "Simple HTML generator", "index.html") app.Trace "Output file = " & outputFileName Dim backgroundImg backgroundImg = InputBox( "Please enter the file name for the background image", " ") app.Trace "Background Image = " & backgroundImg Dim backgroundcolor backgroundcolor = InputBox( "Please enter the color for the background, choices are: black, white, green, blue, red, purple, violet, yellow, and any other basic color", "Simple HTML generator", "white") app.Trace "Background Color = " & backgroundcolor Dim fontcolor fontcolor = InputBox( "Please enter the color for the font, choices are: black, white, green, blue, red, purple, violet, yellow, and any other basic color", "Simple HTML generator", "black") app.Trace "Font Color = " & fontcolor Dim titlename titlename = InputBox( "Use this Title or enter a new Title for the web page to create", "Simple HTML generator", alb.sAlbumTitle ) app.Trace "Web Page Title = " & titlename Dim maintext maintext = InputBox( "Please enter a text description to display in the main window of the web page to create", "Simple HTML generator", alb.sAlbumComment ) app.Trace "Web Page Description = " & maintext Dim backlink backlink = InputBox( "Do you want a back button to a higher level web page?", "Simple HTML generator", "yes" ) app.Trace "Back Button = " & backlink if backlink = "yes" then Dim backname backname = InputBox( "Enter the name of the web file that resides one directory up to link to.", "Simple HTML generator", "index.html" ) app.Trace "File to link to = " & backname end if Dim bgmusic bgmusic = InputBox( "Do you want MIDI music for this web page?", "Simple HTML generator", "no" ) app.Trace "MIDI Music = " & bgmusic if bgmusic = "yes" then Dim midiname midiname = InputBox( "Enter the name of the midi file, you will need to put it in the same directory.", "Simple HTML generator", " .mid" ) app.Trace "MIDI File Name= " & midiname end if Const ForReading = 1, ForWriting = 2 Dim fso, f, m, picPath Set fso = CreateObject("Scripting.FileSystemObject") ' This part works and picPath is equal to the absolute path and pic file name. ' First get the path relative to the album Set pic = alb.GetVisiblePicture(0) picPath = alb.ExpandMacro( pic, "%RP" ) app.Trace "The path for the first picture is " & picPath dim k, pathstring k = instrrev(picPath,"\") ' Search for the last back-slash pathstring = left(picPath, k) app.Trace "The pathstring is " & pathstring Set f = fso.OpenTextFile( pathstring & outputFileName, ForWriting, True) f.WriteLine "" f.WriteLine "" f.WriteLine " " f.WriteLine " " f.WriteLine " " & titlename & "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "<BODY TEXT=" & fontcolor & " BGCOLOR=" & backgroundcolor & ">" f.WriteLine "<p>This page requires a frames capable browser</p>" f.WriteLine "</body>" f.WriteLine "" f.WriteLine "" f.WriteLine "" app.Trace "Page " & outputfilename & " created " f.Close ' ' This section creates the top.html file ' ' Set topFileName = top.html Set f = fso.OpenTextFile( pathstring & "top.html", ForWriting, True) f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "top" f.WriteLine "" f.WriteLine "" if backlink = "yes" then f.WriteLine "" f.WriteLine "" f.WriteLine "" f.WriteLine "
BACK

" & titlename & "

" else f.WriteLine "

" & titlename & "

" end if f.WriteLine "" f.WriteLine "" app.Trace "Page top.html created " f.Close ' ' This section creates the main.html file ' Set f = fso.OpenTextFile( pathstring & "main.html", ForWriting, True) f.WriteLine "" f.WriteLine "" f.WriteLine "main" f.WriteLine "" f.WriteLine "" f.WriteLine "



" f.WriteLine "" f.WriteLine "" f.WriteLine "
" f.WriteLine "
" & maintext & "

" f.WriteLine "
" f.WriteLine "" f.WriteLine "" app.Trace "Page main.html created " f.Close ' ' ' This section creates the menu.html file ' app.Trace "Page menu.html being created " Set f = fso.OpenTextFile( pathstring & "menu.html", ForWriting, True) f.WriteLine "" f.WriteLine "" f.WriteLine " " & titlename & "" f.WriteLine "" f.WriteLine "" f.WriteLine "" if bgmusic = "yes" then f.WriteLine "" end if f.WriteLine "Click Here
" f.WriteLine "
" ' ' ' The following lines go to the creation of the MENU files ' ' ' Process each selected picture Dim nbPic, i, flsh, flshval nbPic = alb.nbVisiblePicture app.Trace "Pictures to process in this album: " & nbPic f.WriteLine "
" f.WriteLine "
" ' Everything is centered for i=0 to nbPic-1 Set pic = alb.GetVisiblePicture(i) if pic.bSelected then f.WriteLine "" f.WriteLine "" ' Important : convert the filename so it is web-compatible Dim picFile, thFile ' First get the path relative to the album picFile = alb.ExpandMacro( pic, "%RP" ) ' Build the name of the thumbnail assuming "_th" is appended ' to the name and its type is the same as the original picture k = instrrev( picFile, "." ) thFile = left(picFile, k-1) & "_th" & mid(picFile, k) f.WriteLine "" f.WriteLine "" f.WriteLine "
" ' SaveFPXRSound ' This script will analyze the selected pictures. If an embedded sound '(FPXR extension in JPEG file) is found the sound is save in a file have the ' same name as the picture. ' dim filename, l, wavSound, wavName pic.load True if pic.getPicDataType(0) = 1 then ' Type 1 is FPXR sound ' Get the relative path of the picture filename = alb.ExpandMacro( pic, "%RP" ) app.Trace " Processing #" & i+1 & " " & filename app.Trace " Found wav data: " & pic.getPicDataSize(0) & " bytes" l = instrrev( filename, "." ) filename = left( filename, l ) & "wav" app.Trace " Saving wav data in '" & filename & "'..." pic.SavePicData 0, filename picFile = pic.sShortFileName l = instrrev( picFile, "." ) wavName = left( picFile, l ) & "wav" ' Build the drop-down list with the picture info f.WriteLine " " & picFile f.WriteLine " " end if pic.load False ' Finish building the drop-down list with the picture info f.WriteLine " " f.WriteLine " " f.WriteLine " " f.WriteLine " " f.WriteLine " " f.WriteLine " " flsh = alb.ExpandMacro( pic, "%C5") if flsh= "" then flshval = "N" else flshval = flsh end if f.WriteLine " " f.WriteLine " " f.WriteLine "" f.WriteLine "
" ' end if ' pic.load False app.Trace "File " & picFile & " added" else app.Trace "File " & picFile & " skipped" end if next f.WriteLine "
" f.WriteLine "
" if backlink = "yes" then f.WriteLine "" f.WriteLine "" f.WriteLine "
BACK
" end if f.WriteLine "Build with MyAlbum script" f.WriteLine "
Created by:
" f.WriteLine "
mpilihp@yahoo.com
" f.WriteLine "
With help by:
" f.WriteLine "
pierre.meindre@libertysurf.fr
" f.WriteLine "
With code from:
" f.WriteLine "
r.p.feria@ieee.org
" f.WriteLine "
Steve@sdean.demon.co.uk
" f.WriteLine "" f.WriteLine "" f.Close app.Trace nbPic & " picture processed." app.Trace "HTML file generation complete !" app.Trace "This script creates a web page that uses thumbnail pictures in the menu." app.Trace "Create these from My Album Tools -> Export Album menu option." app.Trace "Select -Save Thumbnails- then set Output Directory to where this albums images are located, and prest Start!" MsgBox( "Please read the last three lines in trace for instructions on completing this WEB page." & vbcrlf & "Please select OK to continue") ' Launch browser app.Run pathstring & outputFileName, True, 1 else app.Trace "No album to process, exiting !" end if ' ******************************************************************************** ' * ' * GetAlbum : get the current album or prompt the user to select one ' * Function GetAlbum( byref alb ) GetAlbum = True ' First try to use the current album set alb = app.GetCurrentAlbum if alb is nothing then ' No album is open dim albFile albFile = InputBox( "Please enter the name of the album to process", "Simple HTML generator", "") set alb = app.LoadAlbum( albFile ) if alb is Nothing then GetAlbum = False end if end if End Function